home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12558 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: keats.ugrad.cs.ubc.ca!not-for-mail
  2. From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Is this a C BUG??? (A string issue)
  5. Date: 1 Apr 1996 11:13:08 -0800
  6. Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
  7. Message-ID: <4jp9s4INNpp2@keats.ugrad.cs.ubc.ca>
  8. References: <4jknpf$9k3@abel.cc.sunysb.edu> <4jmjgfINN8pr@keats.ugrad.cs.ubc.ca> <AD84A72A96681716E4@mcdiala03.it.luc.edu>
  9. NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
  10.  
  11. In article <AD84A72A96681716E4@mcdiala03.it.luc.edu>,
  12. Verne Arase <VArase@varase.it.luc.edu> wrote:
  13.  >In article <4jmjgfINN8pr@keats.ugrad.cs.ubc.ca>,
  14.  >c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku) wrote:
  15.  >
  16.  > >When in doubt, process individual characters rather than being clever
  17.  >with
  18.  > >buffers and string manipulation. It can be more efficient and cleaner.
  19.  >
  20.  >Even better for fixed length records is open/read/write/close. You can even
  21.  >use non-delimited records. (Why waste the space of a line delimiter, if
  22.  >you're not going to use character formatted data?)
  23.  
  24. You apparently glossed over the problem---can't blame you for that!
  25.  
  26. What is being done is the conversion of non-fixed-length records to
  27. fixed-length records. I fail to see how using low-level POSIX functions would
  28. help, since you would have to pretty much duplicate what the standard IO
  29. library does for you anyway. In fact, you could set a large buffer size on the
  30. standard IO output stream which could cause it to output a whole bunch of
  31. 194-character records at once. A naive implementation of the program using
  32. write() would do the system call for each record.
  33.  
  34. Under reasonable implementations, the putc(char, FILE *) function is a macro
  35. which quickly deposits a character into a buffer (taking advantage of actually
  36. knowing the representation of FILE), and conditionally calling a flush routine
  37. when the buffer is full. This is about as good as banging characters into your
  38. own buffer and calling write() when you fill that up, and it is portable, to
  39. boot.
  40. -- 
  41.  
  42.